package com.sa.web.front.action;

import java.util.ArrayList;
import java.util.List;

import com.opensymphony.xwork2.ActionSupport;
import com.sa.web.bean.NewsBean;
import com.sa.web.dao.service.NewsDao;
import com.sa.web.util.Util;

public class A1001 extends ActionSupport {
	
	private List<NewsBean> newsList;
	
	private NewsDao newsDao;
	
	public String init () throws Exception{
		newsList = newsDao.queryNewsIndex();
		if(newsList == null){
			newsList = new ArrayList<NewsBean>();
			for(int i=0; i<4; i++){
				newsList.add(new NewsBean());
			}
			
		}else{
			for(NewsBean nb : newsList){
				nb.setFlag(Util.subDate(nb.getCreateDate()));
			}
			
			int length = 4-newsList.size();
			for(int i=0;i<length;i++){
				newsList.add(new NewsBean());
			}
		}
		return SUCCESS;
	}

	public List<NewsBean> getNewsList() {
		return newsList;
	}

	public void setNewsList(List<NewsBean> newsList) {
		this.newsList = newsList;
	}

	public NewsDao getNewsDao() {
		return newsDao;
	}

	public void setNewsDao(NewsDao newsDao) {
		this.newsDao = newsDao;
	}

}
